import { requestClient } from '#/api/request';

export function AddObj(form: any) {
  return requestClient.post(`/iam/product/definitions`, form);
}

export function DelObj(id: string) {
  return requestClient.delete(`/iam/product/definitions/${id}`);
}

export function UpdateObj(form: any) {
  return requestClient.put(`/iam/product/definitions/${form.id}`, form);
}

export function GetPage(query: any) {
  return requestClient.post(`/iam/product/definitions/page`, {
    page: { current: query.current, size: query.size },
    model: {
      code: query?.code,
      name: query?.name,
      status: query?.status,
    },
  });
}

export function getPermResByProductId(productId: string) {
  return requestClient.get(
    `/iam/product/definitions/${productId}/permissions`,
    {
      params: { productId },
    },
  );
}

export function assignResource(form: any) {
  return requestClient.put(
    `/iam/product/definitions/${form.productId}/permissions`,
    form,
  );
}

export function GetResourceList(query: any) {
  return requestClient.post('/iam/system/menu/page', {
    page: { current: query.current, size: query.size },
    model: {
      parentId: query?.parentId,
      type: query?.type,
    },
  });
}
